package com.core.dto;

import com.core.model.lxf.Good;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-7-22
 * Time: 下午11:28
 * To change this template use File | Settings | File Templates.
 */
public class GoodDTO {

    private String guid;
    private String name;
    private String age;
    private List<String> strs;
    private Map<String, String> map;

    public GoodDTO() {
    }

    public GoodDTO(String guid, String name, String age) {
        this.guid = guid;
        this.name = name;
        this.age = age;
    }


    public static GoodDTO toDTO(Good good) {
        return new GoodDTO(good.guid(), good.name(), good.age());
    }

    public static List<GoodDTO> toDTOs(List<Good> goods) {
        List<GoodDTO> goodDTOs = new ArrayList<>();
        for (Good g : goods) {
            goodDTOs.add(toDTO(g));
        }
        return goodDTOs;
    }

    public static Good toGood(GoodDTO goodDTO) {
        return new Good(goodDTO.getName(), goodDTO.getAge());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public List<String> getStrs() {
        return strs;
    }

    public void setStrs(List<String> strs) {
        this.strs = strs;
    }

    public Map<String, String> getMap() {
        return map;
    }

    public void setMap(Map<String, String> map) {
        this.map = map;
    }
}
